class Stats(object):
    
    # level 90 conversion
    HIT_RATING_CONVERSION_COEFFICIENT = 340.0
    EXP_RATING_CONVERSION_COEFFICIENT = 340.0
    HASTE_RATING_CONVERSION_COEFFICIENT = 425.0
    CRIT_RATING_CONVERSION_COEFFICIENT = 600.0
    MASTERY_RATING_CONVERSION_COEFFICIENT = 600.0
    
    CRIT_FROM_AGI_CONVERSION_COEFFICIENT = 1259.52
    CRIT_FROM_INT_CONVERSION_COEFFICIENT = 2533.66
    
    MASTERY_BASE_RATE = .08
    
    BASE_AP_CONSTANT = 150
    
    CRIT_DAMAGE_BONUS_META = .03
    
    BASE_MELEE_CRIT_CHANCE = .075
    BASE_SPELL_CRIT_CHANCE = .0186
    
    LEATHER_SPECIALIZATION_MULTIPLIER = 1.05
    
    def __init__(self, race, str, agi, int, hit, exp, haste, crit, mastery, mh, oh, meta):
        self.race = race
        self.str = str
        self.agi = agi
        self.int = int
        self.ap = self.str + self.agi * 2
        self.hit = hit
        self.exp = exp
        self.haste = haste
        self.crit = crit  
        self.mastery = mastery
        self.mh = mh
        self.oh = oh
        self.meta = meta
        
    def get_hit_from_rating(self):
        return self.hit / (self.HIT_RATING_CONVERSION_COEFFICIENT * 100)
    
    def get_exp_from_rating(self, weapon_type):
        return self.exp / (self.EXP_RATING_CONVERSION_COEFFICIENT * 100)
    
    def get_exp_rate_total(self, weapon_type):
        exp = self.get_exp_from_rating(weapon_type)
        if weapon_type == '1H_FIST':
            exp += self.race.get_racial_expertise_fist()
        elif weapon_type == '1H_SWORD' or weapon_type == '2H_SWORD':
            exp += self.race.get_racial_expertise_sword()
        elif weapon_type == '1H_AXE' or weapon_type == '2H_AXE':
            exp += self.race.get_racial_expertise_axe()
        elif weapon_type == '1H_MACE' or weapon_type == '2H_MACE':
            exp += self.race.get_racial_expertise_mace()
            
        return exp
    
    def get_haste_from_rating(self):
        return self.haste / (self.HASTE_RATING_CONVERSION_COEFFICIENT * 100)
        
    def get_crit_from_rating(self):
        return self.crit / (self.CRIT_RATING_CONVERSION_COEFFICIENT * 100)
    
    def get_mastery_from_rating(self):
        rate = self.MASTERY_BASE_RATE + self.mastery / (self.MASTERY_RATING_CONVERSION_COEFFICIENT * 100)
        return rate
    
    def get_crit_from_agi(self):
        # TODO
        base_agi = 19
        return self.BASE_MELEE_CRIT_CHANCE + (self.agi - base_agi) / (self.CRIT_FROM_AGI_CONVERSION_COEFFICIENT * 100)
    
    def get_crit_from_int(self):
        # TODO
        base_int = 20
        return self.BASE_SPELL_CRIT_CHANCE + (self.int - base_int) / (self.CRIT_FROM_INT_CONVERSION_COEFFICIENT * 100)
    
    def get_meta_crit_damage_multiplier(self):
        if self.meta:
            return 1 + self.CRIT_DAMAGE_BONUS_META
        else:
            return 1
        
    # TODO
    def is_leather_specialization(self):
        return True
    
    # TODO
    def is_monk_2T14_windwalker(self):
        return True
    
    # TODO
    def is_monk_4T14_windwalker(self):
        return True
    
    def get_armor_specializationm_multiplier(self):
        return self.is_leather_specialization() * self.LEATHER_SPECIALIZATION_MULTIPLIER
    
    
    
    
class Race(object):
    
    RACIAL_PADARIAN_FOOD_MULTIPLIER = 2.0
    
    # Expertise
    RACIAL_SWORD_EXP_CHANCE = .01 # Human / Gnome
    RACIAL_MACE_EXP_CHANCE = .01 # Human / Dwarf
    RACIAL_AXE_EXP_CHANCE = .01 # Orc
    RACIAL_FIST_EXP_CHANCE = .01 # Orc
    
    def __init__(self, race):
        self.race = race    
    
    def get_food_value_multiplier_racial(self):
        if self.race == 'PANDARIAN':
            return self.RACIAL_PADARIAN_FOOD_MULTIPLIER
        return 1
    
    def get_racial_expertise_fist(self):
        if self.race == 'ORC':
            return self.RACIAL_FIST_EXP_CHANCE
        return 0
    
    def get_racial_expertise_sword(self):
        if self.race == 'HUMAN' or self.race == 'GNOME':
            return self.RACIAL_SWORD_EXP_CHANCE
        return 0
    
    def get_racial_expertise_mace(self):
        if self.race == 'HUMAN' or self.race == 'DWARF':
            return self.RACIAL_MACE_EXP_CHANCE
        return 0
    
    def get_racial_expertise_axe(self):
        if self.race == 'ORC':
            return self.RACIAL_AXE_EXP_CHANCE
        return 0